#delimit;
pause on;
clear all;
set mem 50m;
pause;
set more off;
pause;
cd "C:\data\Veto points\JOP_December08\Replication";
pause;
use "veto0208_replication_v3.dta", clear;
log using appendix.smcl, replace;



/*Multinomial Logit*/

generate reform_trich=1 if d.EBRD>0;
replace reform_trich=-1 if d.EBRD<0;
replace reform_trich=0 if d.EBRD==0;


/*Models 1 and 2: No Controls*/
xi3: mlogit reform_trich checks_new lag_EBRD inter_checks_lagEBRD if country_<26, cluster(country_) baseoutcome(0);
outreg2 using TableA4, e(all) bdec(3) tdec(3) replace;

/*Models 3 and 4: Full set of Controls*/
xi3: mlogit reform_trich checks_new postcoms lag_EBRD inter_checks_lagEBRD  wart ln_gdpcap   if country_<26, cluster(country_) baseoutcome(0);
outreg2 using TableA4, e(all) bdec(3) tdec(3);

/*Models 5 and 6: Full set of Controls, Year FE*/
xi3: mlogit reform_trich checks_new postcoms lag_EBRD inter_checks_lagEBRD  wart ln_gdpcap i.year if country_<26, cluster(country_) baseoutcome(0);
outreg2 using TableA4, e(all) bdec(3) tdec(3);

/*Models 7 and 8: Two-Way FE*/
xi3: mlogit reform_trich checks_new postcoms lag_EBRD inter_checks_lagEBRD  wart ln_gdpcap  i.year i.country_  if country_<26, cluster(country_) baseoutcome(0);
outreg2 using TableA4, e(all) bdec(3) tdec(3) excel;




/*Figure A2*/
#delimit;
egen sd_reform=rowsd( price forextrade smallpriv largepriv entreform comppolicy bankref nonbank);

foreach x in  price forextrade smallpriv largepriv entreform comppolicy bankref nonbank {;
generate d_`x'=(d.`x');
};

egen sd_d_reform=rowsd( d_price d_forextrade d_smallpriv d_largepriv d_entreform d_comppolicy d_bankref d_nonbank);

egen maxreform = max(EBRD), by(country_);

egen maxposchange = max(change_mag_positive), by(country_);

egen maxsdreform = max( sd_reform), by(country_);

generate maxyear_sdreform=sd_reform if EBRD==maxreform;
egen maxyear_sdreform2=max(maxyear_sdreform), by(country_);


preserve;

collapse (mean) maxreform maxposchange  maxsdreform maxyear_sdreform country_, by(ctrynm);

/*Standard Deviation of Reform Type at Maximum Reform Change*/

twoway (lfitci maxyear_sdreform   maxposchange) (scatter   maxyear_sdreform   maxposchange if country_ < 26, mlabel(  ctrynm) msize(small) 
mcolor(blue) mlabcolor(black) mlabsize(vsmall) msymbol(diamond)), ytitle("Standard Deviation Among Types at Highest Total Reform", 
size(medsmall)) xtitle("Maximum Annual Reform Change", size(medsmall)) legend(off);
pause;

graph save var_maxrefchange.gph, replace;


/*Maximum Reform Change and Max Reform*/

twoway (lfitci maxreform maxposchange) (scatter   maxreform  maxposchange if country_ < 26, mlabel(  ctrynm) msize(small) 
mcolor(blue) mlabcolor(black) mlabsize(vsmall) msymbol(diamond)), ytitle("Highest Level of Total Reform", 
size(medsmall)) xtitle("Maximum Annual Reform Change", size(medsmall)) legend(off);
pause;

graph save maxreform_maxchange.gph, replace;

graph combine maxreform_maxchange.gph var_maxrefchange.gph, xcommon;

graph save FigureA2, replace;


restore;


save "veto0208_replication_v4.dta", replace;
log close;
